<!DOCTYPE html>
<html lang="en">

<head>
    <#include "/jh/admin/components/meta.html" />
    <title>权限管理 ${metaTitleSuffix!}</title>
    <#include "/jh/admin/components/stylesheets.html" />
</head>

<body>
    <div id="app">
        <el-container>
            <#assign menuIndex="3-2" />
            <#include "/jh/admin/components/menu.html" />
            <el-container>
                <#include "/jh/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-row>
                            <el-col :span="12">
                                <div class="title theme-color1">权限管理</div>
                            </el-col>
                            <el-col :span="12">
                                <div class="operations">
                                    <el-button type="success" size="small" @click="add"><i class="el-icon-plus"></i>添加</el-button>
                                </div>
                            </el-col>
                        </el-row>
                        <el-table ref="multipleTable" :data="list" tooltip-effect="dark" :stripe='true' style="width: 100%">
                            <el-table-column prop="columns.name" label="权限名称" show-overflow-tooltip>
                            </el-table-column>
                            <el-table-column fixed="right" label="操作" width="100">
                                <template slot-scope="scope">
                                    <el-button @click="edit(scope.row.columns)" type="text" size="small">编辑</el-button>
                                    <el-button @click="del(scope.row.columns)" type="text" size="small" style="color: red;">删除</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <#include "/jh/admin/components/page.html" />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/jh/admin/components/footer.html" />
    </div>
    <#include "/jh/admin/components/scripts.html" />
    <script>
        var vue = new Vue({
        el: '#app',
        data() {
            return {
                list: []
            }
        },
        mounted: function() {
            // var str = '${items!}'
            // if (str != '') {
            //     this.list = JSON.parse(str);
            // }
        },
        methods: {
            add() {
                window.location.href = "/jh/admin/role/info";
            },
            edit(item) {
                window.location.href = "/jh/admin/role/info?roleId=" + item.id;
            },
            del(item) {
                var self = this;
                confirm("确认删除？请谨慎操作", "确认", function() {
                    var param = Qs.stringify({
                        roleId: item.id
                    });
                    axios({
                        url: '/jh/admin/role/delete',
                        method: 'post',
                        data: param,
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded'
                        }
                    })
                    .then(function(response) {
                        if (response.data.status == 200) {
                            endLoading();
                            window.location.href = "/jh/admin/role/list";
                            // msg("登录成功");
                        } else {
                            endLoading();
                            msg(response.data.msg);
                            console.log(response.data);
                        }
                    })
                    .catch(function(error) {
                        endLoading();
                        msg("删除失败");
                        console.log(error);
                    });
                })
            },
            onPageChange(val) {
                // console.log('当前页: {val}' + val);
                goPage(val)
            }
        }
    })
    </script>
    <script>
        vue.list = ${items!}
    </script>
    <#include "/jh/admin/components/msg.html" />
    <style type="text/css">
    .title {
        font-size: 18px;
        font-weight: bold;
    }

    .operations {
        text-align: right;
    }
    </style>
</body>

</html>